<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0">
    <meta name="description" content="">
    <meta name="author" content="ThemeBucket">
    <link rel="shortcut icon" href="#" type="image/png">
    <title>Form Layouts</title>
    <link rel="stylesheet" type="text/css" href="/public/js/ios-switch/switchery.css" />
    <link rel="stylesheet" type="text/css" href="/public/js/jquery-tags-input/jquery.tagsinput.css" />
    <link rel="stylesheet" type="text/css" href="/public/js/jquery-multi-select/css/multi-select.css" />
    <?php $this->load->view('library/header');?>
</head>
<body class="sticky-header">
<section>
    <?php $this->load->view('library/left');?>
    <div class="main-content" >
        <?php $this->load->view('library/top');?>
        <div class="page-heading">
            <h3>
                商品批量更新
            </h3>
            <ul class="breadcrumb">
                <li>
                    <a href="#">Forms</a>
                </li>
                <li class="active"> Forms Layouts </li>
            </ul>
        </div>
        <section class="wrapper">
            <div class="row">
                <div class="col-lg-12">
                    <section class="panel">
                        <header class="panel-heading">
                            更新
                            <span class="tools pull-right">
                                <a class="fa fa-chevron-down" href="javascript:;"></a>
                            </span>
                        </header>
                        <div class="panel-body">
                            <div class="form-group">
                                <label class="col-sm-2 control-label col-lg-2" for="inputSuccess" style="width: 105px">商品货号 :</label>
                                <textarea name="goods_sn" class="goods_sn" cols="30" rows="10"></textarea>
                                <div style="width: 23%;height: 205px; float: right; margin-right: 42%;">
                                   
                                <select multiple="multiple" class="multi-select" id="my_multi_select1" name="web_id[]">
                                    <?php foreach ($res as $k => $v) :?>
                                        <option value="<?php echo $v['web_id'];?>"><?php echo $v['web_name'];?></option>
                                    <?php endforeach;?>
                                </select>
                                </div>
                            </div>
                        </div>
                        <footer class="panel-footer">
                            <button style="margin-right: 85%;" type="submit" class="btn btn-post pull-right upload">更新</button>
                            <ul class="nav nav-pills p-option"></ul>
                        </footer>
                    </section>
                </div>
            </div>
        </section>
        <footer>
            2014 &copy; AdminEx by
        </footer>
    </div>
</section>
<?php $this->load->view('library/footer');?>
</body>
</html>
<script type="text/javascript" src="/public/js/jquery-multi-select/js/jquery.multi-select.js"></script>
<script src="/public/js/multi-select-init.js"></script>
<script src="/public/js/scripts.js"></script>
<script>
    $('.upload').click(function(){
        var goods_sn = $.trim($('.goods_sn').val());
        var web_id = $("#my_multi_select1").val();

        swal({
            title: '商品批量更新',
            showCancelButton: true,
            preConfirm: function preConfirm(value) {
                swal({
                    imageUrl: '/public/images/Forrest.gif',
                    title: '稍等...',
                    allowOutsideClick: false,
                    showConfirmButton: false
                });
                return $.post("<?php echo base_url('ShopifyGoods/update_all');?>", {goods_sn: goods_sn,web_id:web_id}, function (data) {
                    return data;
                },'json');
            }
        }).then(function (result) {
            if (result.value) {
                var data = result.value;
                swal({
                    type: data.status,
                    title: data.info
                }).then(function(isConfirm) {
                    location.reload();
                });
            }
        });
    })
</script>
